package org.cycuchy.hp.components.book {
	
	import com.rubenswieringa.book.Page;
	
	import mx.events.FlexEvent;

	public class BackgroundImagePage extends Page {

        [Embed(source='assets/embed/img/page1.jpg')]
		private static const backgroundImage1Class:Class;		

//        [Embed(source='assets/embed/img/page2.jpg')]
//		private static const backgroundImage2Class:Class;		
//		
//        [Embed(source='assets/embed/img/page3.jpg')]
//		private static const backgroundImage3Class:Class;		
//
//        [Embed(source='assets/embed/img/page4.jpg')]
//		private static const backgroundImage4Class:Class;		
//
//        [Embed(source='assets/embed/img/page5.jpg')]
//		private static const backgroundImage5Class:Class;		

        [Embed(source='assets/embed/img/page6.jpg')]
		private static const backgroundImage6Class:Class;		
		
		private static const backgrounds:Array = [backgroundImage1Class,
			/* 
			backgroundImage2Class, backgroundImage3Class,
			backgroundImage4Class, backgroundImage5Class,
			*/ 
			backgroundImage6Class];
		
		private var _addBackground:Boolean = true;
		
		public function BackgroundImagePage() {
			super();
			addEventListener(FlexEvent.CREATION_COMPLETE, creationComplete);
		}
		
		private function creationComplete(event:FlexEvent):void {
			removeEventListener(FlexEvent.CREATION_COMPLETE, creationComplete);
			if (_addBackground == true) {
				setStyle("backgroundImage", backgrounds[uint(Math.random() * 10) % backgrounds.length]);
			}			
		}
		
		public function set addBackground(value:Boolean):void {
			_addBackground = value;
		}
		
	}
	
}